#ifndef SINGLETON_H
#define SINGLETON_H

#include <boost/utility.hpp>

template<typename T>
class Singleton : public boost::noncopyable
{
    public:

        static T* get()
        {
            if(m_singleton == 0)
                m_singleton = new T;

            return m_singleton;
        }

        static void destroy()
        {
            if(m_singleton != 0)
            {
                delete m_singleton;
                m_singleton = 0;
            }
        }

    protected:

        static T* m_singleton;

        Singleton() {}
};

template <typename T>
T* Singleton<T>::m_singleton = 0;

#endif // SINGLETON_H
